package com.educationx;

import java.util.List;

import android.content.Context;
import android.view.LayoutInflater;
import android.view.View;
import android.view.ViewGroup;
import android.widget.ArrayAdapter;
import android.widget.TextView;

public class LectureListArrayAdapter extends ArrayAdapter<Lecture> {
	private Context context;
	private List<Lecture> items;

	public LectureListArrayAdapter(Context context, int textViewResourceId, List<Lecture> items) {
		super(context, textViewResourceId, items);
		this.context = context;
		this.items = items;
	}
	
	@Override
	public View getView(int position, View convertView, ViewGroup parent) {
		View v = convertView;
		if (v == null) {
			LayoutInflater vi = (LayoutInflater) context.getSystemService(Context.LAYOUT_INFLATER_SERVICE);
			v = vi.inflate(R.layout.row_lecture, parent, false);
		}
		final Lecture item = items.get(position);
		if (item != null) {
			TextView tw1 = (TextView) v.findViewById(R.id.textViewLectureName);
			TextView tw2 = (TextView) v.findViewById(R.id.textViewLink);
			if (tw1 != null) {
				tw1.setText(item.getName());                            
			}
			if (tw2 != null) {
				tw2.setText(item.getLink());                            
			}
		}
		return v;
	}
}
